-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LIB_SYS_TRY_SHARED ENV var to try to link with shared library #206
base: main
Are you sure you want to change the base?
Add LIB_SYS_TRY_SHARED ENV var to try to link with shared library #206
Conversation
On cross-compilation libz-sys is always building static zlib library, except for Apple platforms. If target has an installed zlib shared library, this is problem, because: 1. the binary is increased, because we are including a static zlib as well 2. it may cause build issues if the pkg-config sets the linker arguments, like this: /tmp/rustc0ZqD0F/liblibz_sys-84983a050a121d20.rlib(inflate.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol '__stack_chk_guard' which may bind externally can not be used when making a shared object; recompile with -fPIC To workaround the issue, add a LIB_SYS_TRY_SHARED=1 ENV var (similarly to LIBZ_SYS_STATIC=1) to force the use of the shared library, recognized by the pkg-config. fixes rust-lang#201
612984b
to
2422982
Compare
Thanks a lot for tackling this. @jongiddy I feel that Thanks everyone for your help. |
Neither option is ideal. Using an environment variable means there is a hidden dependency that affects the build. When anyone needs support, it is an extra relevant piece of information they need to supply. And it is easy to not be aware whether it is set or not. Using a feature is painful when a transitive dependency is deeply nested, and Pragmatically, since there is already an environment variable for controlling static vs dynamic, I'd accept using an environment variable here. However, I suggest that the existing variable is reused, so that setting |
FWIW there is precedent in other
|
Thanks a lot for the summary, it's good to know the standards. This PR is at a stage where the question remains if |
This one is interesting. Matches the proposed one variable model with 0 meaning force dynamic and 1 meaning force static. |
I'm hitting this when trying to cross-compile a project. |
I think this patch is stuck on this question along with the implementation lacking discoverability as there are no docs at all. |
Is there something I can do in the meanwhile to be able to cross-compile the project I'm looking at? |
One could tell Cargo to use the patched version of the dependency (with |
In my case this does not seem to help.
with zlib manually installed, just in case - and this in a Debian image:
and I patch libz-sys by:
but it seems to not understand, and the aarch64 compiler is called with invalid flags
The project I'm trying to cross-compile (from amd64) is this one: https://github.com/BoltzExchange/boltz-backend.git |
Maybe a different issue? The local override can also point to a local checkout of the crate, which might help to make adjustments to |
Yes, this was related to something else. I managed to cross-compile by overriding the dependency. Thanks. :) |
On cross-compilation libz-sys is always building static zlib library, except for Apple platforms. If target has an installed zlib shared library, this is problem, because:
the binary is increased, because we are including a static zlib as well
it may cause build issues if the pkg-config sets the linker arguments, like this:
/tmp/rustc0ZqD0F/liblibz_sys-84983a050a121d20.rlib(inflate.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol '__stack_chk_guard' which may bind externally can not be used when making a shared object; recompile with -fPIC
To workaround the issue, add a LIB_SYS_TRY_SHARED=1 ENV var (similarly to LIBZ_SYS_STATIC=1) to force the use of the shared library, recognized by the pkg-config.
fixes #201